# Contributor: Jake Buchholz Göktürk <tomalok@gmail.com>
# Maintainer: Jake Buchholz Göktürk <tomalok@gmail.com>
pkgname=galera
pkgver=26.4.13
pkgrel=3
# requires commits beyond officially tagged release_v26
#_wsrep_tag=release_v26
_wsrep_commit=694d6ca47f5eec7873be99b7d6babccf633d1231
pkgdesc="Galera replication - Codership's implementation of the write set replication (wsrep) interface"
url="https://galeracluster.com"
license="GPL-2.0-or-later"
depends="mariadb"
makedepends="bash boost-dev check-dev cmake openssl-dev>3"
subpackages="$pkgname-arbitrator $pkgname-arbitrator-doc:arbitrator_doc"
arch="x86 x86_64 s390x"
source="
	https://github.com/codership/galera/archive/release_$pkgver.tar.gz
	https://github.com/codership/wsrep-API/archive/$_wsrep_commit.tar.gz
	fix_gcomm-test-check_evs2.patch
	generate-cert-for-tests.patch
	musl-page-size.patch
	musl-sched_param.patch
	musl-wordsize.patch
"
builddir="$srcdir/$pkgname-release_$pkgver"

prepare() {
	default_prepare

	ln -s /usr/bin/python3 python
	export PATH="$PATH:."
}

build() {
	rmdir wsrep/src
	cp -a ../wsrep-API-$_wsrep_commit wsrep/src
	cmake .
	make
}

check() {
	make test
}

package() {
	mkdir -p "$pkgdir/usr/lib"
	mv libgalera_smm.so "$pkgdir/usr/lib"
}

arbitrator() {
	url="https://galeracluster.com/library/documentation/arbitrator.html"
	depends=""
	mkdir -p "$subpkgdir/usr/sbin"
	mv "$builddir/garb/garbd" "$subpkgdir/usr/sbin"
}

arbitrator_doc() {
	url="https://galeracluster.com/library/documentation/arbitrator.html"
	depends=""
	mkdir -p "$subpkgdir/usr/share/man/man8"
	mv "$builddir/man/garbd.8" "$subpkgdir/usr/share/man/man8"
	gzip "$subpkgdir/usr/share/man/man8/garbd.8"
}

sha512sums="
34bd8eecf45efe8237256672eb164060ef4f8b9548b0da4392d6c45507f215d85272bf9fe883ec365ae8541051edc4c1a8b9f2d4bd9158100264bd824cc6cc61  release_26.4.13.tar.gz
4bf11c9ea43263cddebfebe115ea4118a1d5573f30f160a7fc7db9ae7faa4d1f11c5f0988ce4d4878d49431635b9e1b0c9ec3bfe0f8cda7c3b6d1d6c7265a391  694d6ca47f5eec7873be99b7d6babccf633d1231.tar.gz
7e3835046be86bcf36e08de85e3577dc9e56d19b89c0cb9270158d793576428f3d19ff420556a7bc6ddeb0721f6032e23e68952f903e15415e16cf524164663c  fix_gcomm-test-check_evs2.patch
964880ac75bd4a973f82fd87eea6b9f5333a63352968d40086ab62f856d1d30f2e1ab3b797b14286432af7e376ed62ca0d64e232942ef9ff601a51b501501224  generate-cert-for-tests.patch
196bae14790d6dad46617d107b5ddac6f01694468fb7a049736c6a21c9857b490863eec66be774eeb01300c0dbf4d9871a1b89da6847d92d67473b3aa80dbd3e  musl-page-size.patch
de08e34bf52cb39353a72a3608053d9204edcddd24f2f7babe2e5eb753d91bd0ca5909ee07a4d6c7ad54e37fba37ad2866403f1805401dcb68b9958514e17ac2  musl-sched_param.patch
2baf88a6c16360ba1ac2ddf7a87a33f84b3039ca9819d84cfdd96b702da1a6050be1b4ac1f3fe6eff7f539158cdb6369906c4821545b1292d98899ec6e13b249  musl-wordsize.patch
"
